//打击犯罪
#include <iostream>;
#include <vector>
using namespace std;
const int MAXN=1000;
int n;
vector<int> rela[MAXN+1];
struct node
{
    int head,next,last,size;
};
struct  UFS
{
    node s[MAXN+1];
    void init(){
        for(int i=1;i<=n;i++){
            s[i].head=i;
            s[i].next=0;
            s[i].last=i;
            s[i].size=1;
        }
    }
    int find_set(int x){
        return s[x].head;
    }
    void  addto(int hx,int hy){
        s[s[hx].last].next=hy;
        s[hx].last=s[hy].last;
        s[hx].size+=s[hy].size;
        while(hy>0){
            s[hy].head=hx;
            hy=s[hy].next;
        }
    }
    void union_set(int x,int y){
        int hx=find_set(x);
        int hy=find_set(y);
        if (hx!=hy){
            if (s[hx].size>s[hy].size) addto(hx,hy);
            else addto(hy,hx);
        }
    }
    int get_size(int x){
        return s[s[x].head].size;
    }
};
UFS ufs;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        int m;
        cin>>m;
        for(int j=1;j<=m;j++){
            int k;
            cin>>k;
            rela[i].push_back(k);
            rela[k].push_back(i);
        }
    }
    int left=1,right=n;

    while(left<right){
        int mid=(left+right)/2;
        ufs.init();
        bool can=true;
        for(int u=mid+1;u<=n;u++){
            for(int j=0;j<rela[u].size();j++){
                int v=rela[u][j];
                if (v>mid) {
                    ufs.union_set(u,v);
                    if (ufs.get_size(u)>n/2) {
                        can=false;
                        break;
                    }
                }
            }
            if (!can) break;
        }
        if (can) {
            right=mid;
        }else {
            left=mid+1;
        }
    }
    cout<<right;
}